/**
 * @file   FrmEval.java
 * @author Enrique Madrid <e.madrid@lpcsite.com>
 * @date   Wed Aug 15 16:46:39 2007
 * 
 * @brief  
 * 
 * 
 */
package sim.forms;

import java.util.*;

public final class FrmEval {

    private FrmCalc  m_FrmCalc;

    public FrmEval() {

    }

    protected void setFrmCalc(FrmCalc calc) {
	m_FrmCalc = calc;
    }

    protected int equal(FrmNode node) {
	Enumeration e;
	FrmItem item;
	if (node.m_Items != null) {
	    e = node.m_Items.elements();
	    while(e.hasMoreElements()) {
		item = (FrmItem)e.nextElement();
		if (m_FrmCalc.calcEqual(item)) {
		    return item.m_Node;
		}
	    }
	}
	return FrmNode.NODE_NEXT;
    }

    protected int minor(FrmNode node) {
	Enumeration e;
	FrmItem item;
	if (node.m_Items != null) {
	    e = node.m_Items.elements();
	    while(e.hasMoreElements()) {
		item = (FrmItem)e.nextElement();
		if (m_FrmCalc.calcMinor(item)) {
		    return item.m_Node;
		}
	    }
	}
	return FrmNode.NODE_NEXT;
    }

    protected int major(FrmNode node) {
	Enumeration e;
	FrmItem item;
	if (node.m_Items != null) {
	    e = node.m_Items.elements();
	    while(e.hasMoreElements()) {
		item = (FrmItem)e.nextElement();
		if (m_FrmCalc.calcMajor(item)) {
		    return item.m_Node;
		}
	    }
	}
	return FrmNode.NODE_NEXT;
    }

    protected int majorORequal(FrmNode node) {
	Enumeration e;
	FrmItem item;
	if (node.m_Items != null) {
	    e = node.m_Items.elements();
	    while(e.hasMoreElements()) {
		item = (FrmItem)e.nextElement();
		if (m_FrmCalc.calcMajEq(item)) {
		    return item.m_Node;
		}
	    }
	}
	return FrmNode.NODE_NEXT;
    }

    protected int minorORequal(FrmNode node) {
	Enumeration e;
	FrmItem item;
	if (node.m_Items != null) {
	    e = node.m_Items.elements();
	    while(e.hasMoreElements()) {
		item = (FrmItem)e.nextElement();
		if (m_FrmCalc.calcMinEq(item)) {
		    return item.m_Node;
		}
	    }
	}
	return FrmNode.NODE_NEXT;
    }

}
